using System.Collections.Generic;

using Cleanuparr.Persistence.Models.Configuration.MalwareBlocker;

namespace Cleanuparr.Api.Features.MalwareBlocker.Contracts.Requests;

public sealed record UpdateMalwareBlockerConfigRequest
{
    public bool Enabled { get; init; }

    public string CronExpression { get; init; } = "0/5 * * * * ?";

    public bool UseAdvancedScheduling { get; init; }

    public bool IgnorePrivate { get; init; }

    public bool DeletePrivate { get; init; }

    public bool DeleteKnownMalware { get; init; }

    public BlocklistSettings Sonarr { get; init; } = new();

    public BlocklistSettings Radarr { get; init; } = new();

    public BlocklistSettings Lidarr { get; init; } = new();

    public BlocklistSettings Readarr { get; init; } = new();

    public BlocklistSettings Whisparr { get; init; } = new();

    public List<string> IgnoredDownloads { get; init; } = [];

    public ContentBlockerConfig ApplyTo(ContentBlockerConfig config)
    {
        config.Enabled = Enabled;
        config.CronExpression = CronExpression;
        config.UseAdvancedScheduling = UseAdvancedScheduling;
        config.IgnorePrivate = IgnorePrivate;
        config.DeletePrivate = DeletePrivate;
        config.DeleteKnownMalware = DeleteKnownMalware;
        config.Sonarr = Sonarr;
        config.Radarr = Radarr;
        config.Lidarr = Lidarr;
        config.Readarr = Readarr;
        config.Whisparr = Whisparr;
        config.IgnoredDownloads = IgnoredDownloads;

        return config;
    }
}
